﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />

var currentClip;

myapp.Md12TraingroupAddEdit.Delete_execute = function (screen) {
    // Alert
    var resp = msls.showMessageBox("Die Trainingsgruppe wird nun gelöscht, sofern keine Trainingseinheiten zugeordnet sind.", { title: 'Wirklich löschen?', buttons: msls.MessageBoxButtons.yesNo });
    resp.then(function (val) {
        if (val == msls.MessageBoxResult.yes) {
            screen.tlTraingroup.deleteEntity();
            return myapp.commitChanges().then(null, function fail(e) {
                myapp.cancelChanges();
                throw e;
            });
        }
    });
};

myapp.Md12TraingroupAddEdit.created = function (screen) {
    // Title
    if (screen.details.displayName != undefined)
        screen.details.displayName = screen.tlTraingroup.Name;
    else
        screen.details.displayName = 'Neue Trainingsgruppe';

    // Set Default eMail PropertyId
    screen.mailPropertyId = 4;

    // 
};

myapp.Md12TraingroupAddEdit.tbStakeholder_postRender = function (element, contentItem) {
    // Mark deleted Stakeholder in red
    var entity = contentItem.value;
    if (entity.IsDeleted) {
        color = "#F5858B";
        $(element).closest("li").css("background", color);
    }
    refresh();
    entity.addChangeListener("IsDeleted", refresh);
};

myapp.Md12TraingroupAddEdit.emailBox_postRender = function (element, contentItem) {
    element.firstChild.readOnly = true;
};

